home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Inspectors / InspectMe / ColorInspector.m < prev    next >
Text File  |  1995-06-12  |  2KB  |  90 lines

  1. // ColorInspector.m
  2. // By Kevin Brain (ksbrain@zeus.UWaterloo.ca)
  3.  
  4. // Acts as an intermediary between the color inspector 
  5. // view controls (layed out in the file ColorInspector.nib)
  6. // and the objects they inspect. 
  7.  
  8. #import "ColorInspector.h"
  9. #import "InspectMeApp.h"
  10. #import "InspectorManager.h"
  11. #import "Thing1.h"
  12. #import <appkit/NXColorWell.h>
  13. #import <appkit/Control.h>            // displaying attributes 
  14.  
  15. @implementation ColorInspector
  16.  
  17. static id theColorInspector = nil;    // just one per class 
  18.  
  19.  
  20. // only a single instance of this class is permitted
  21. //  use [ColorInspector new] to return the single instance
  22.  
  23. + new
  24. {
  25.     if (!theColorInspector) {
  26.         theColorInspector = self = [super new];
  27.         if ([NXApp loadNibSection:"ColorInspector.nib" owner:self] == nil)
  28.             printf("Couldn't load ColorInspector.nib\n");
  29.         }
  30.     else 
  31.         self = theColorInspector;
  32.     return self;
  33. }
  34.  
  35. - setupInspectors:(id)mainInspector
  36. {
  37.     inspectorManager = [NXApp inspectorManager];
  38.     bkgndColorInspectorNum = [inspectorManager 
  39.         addInspector:(id)colorBox 
  40.         title:(const char *)"Background Color Inspector"
  41.         atLocation:LOWERLEFTX :LOWERLEFTY
  42.         cached:YES cacheWindow:[colorBox window]];
  43.  
  44.     return self;
  45. }
  46.  
  47. - setCurrentParameterReceiver:(id)newCurrent
  48. {
  49.     currentParameterReceiver = newCurrent;
  50.     return self;
  51. }
  52.     
  53. - (unsigned int)bkgndColorInspectorNum
  54. {
  55.     return bkgndColorInspectorNum;
  56. }
  57.  
  58. - reflectbkgndColorAttributes:(id)theObject
  59. {
  60.     if(!theObject) return self;
  61.     
  62.     [graySliderOut setFloatValue:[theObject bkgndGray]];
  63.     [colorWellOut setColor:[theObject bkgndColor]];
  64.  
  65.     return self;
  66. }
  67.  
  68. /* Setting ingredient attribute values */
  69. /*   Targets of inspector controls   */
  70. /* NOTE: No range checking has been added to these methods yet. */
  71.  
  72. - inspSetGray:sender
  73. {
  74.     [currentParameterReceiver setBkgndGray:[sender floatValue]];
  75.     [colorWellOut setColor:NXConvertGrayToColor([sender floatValue])];
  76.     return self;
  77. }
  78.  
  79. - inspSetColor:sender
  80. {
  81.     float    aFloat;
  82.     
  83.     [currentParameterReceiver setBkgndColor:[sender color]];
  84.     NXConvertColorToGray([sender color],&aFloat);
  85.     [graySliderOut setFloatValue:aFloat];
  86.     return self;
  87. }
  88.  
  89. @end
  90.